package com.tradeplus.admin.dao;

import com.tradeplus.admin.model.Theme;
import java.util.List;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class ThemeDaoImpl implements ThemeDao {

    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }
    
    @Override
    public void deleteTheme(Long themeId) {
        hibernateTemplate.delete(hibernateTemplate.get(Theme.class, themeId));
    }

    @Override
    public List<Theme> loadTheme() {
        return hibernateTemplate.find("from Theme");
    }

    @Override
    public Theme loadThemeById(Long themeId) {
        return (Theme) hibernateTemplate.get(Theme.class, themeId);
    }

    @Override
    public void saveTheme(Theme theme) {
        hibernateTemplate.merge(theme);
    }
    
    
}
